<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<% String basePath = request.getContextPath(); %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>


<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>国台会务系统</title>
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="<%=basePath%>/resources/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="<%=basePath%>/resources/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="<%=basePath%>/resources/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="<%=basePath%>/resources/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="<%=basePath%>/resources/assets/css/app.css">
    <link href="<%=basePath%>/resources/css/mui/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="<%=basePath%>/resources/assets/css/amazeui.datetimepicker.css">
    
    <script src="<%=basePath%>/resources/assets/js/jquery.min.js"></script>
    <script src="<%=basePath%>/resources/assets/js/amazeui.datetimepicker.min.js"></script>
    <script src="<%=basePath%>/resources/assets/js/locales/amazeui.datetimepicker.zh-CN.js"></script>

</head>

<body data-type="login">
    <script src="<%=basePath%>/resources/assets/js/theme.js"></script>
    
      <div class="row">

        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">
                    	编辑或查看用户信息
                    </div>
                </div>
                
                <div class="widget-body am-fr">
                    <form class="am-form tpl-form-border-form tpl-form-border-br"  action="${ctx}/userSystem/index"  method="post" onsubmit="return verification();" >
                        <div class="am-form-group" style="display:none;">
                            <label for="user-name" class="am-u-sm-3 am-form-label">用户名<span class="tpl-form-line-small-title"> userName</span></label>
                            <div class="am-u-sm-9">
                                <input type="text" class="tpl-form-input" id="userName" name ="userName" value="${user.userName}" placeholder="用户名">
                                <input type="hidden" class="tpl-form-input" id="userId" name ="userId" value="${user.userId}" placeholder="id">
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>
                      
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">姓名<span class="tpl-form-line-small-title"> realName</span></label>
                            <div class="am-u-sm-9">
         						  <input type="text" class="tpl-form-input" id="realName" name ="realName" value="${user.realName}" placeholder="姓名">
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>
                        
                        
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">性别<span class="tpl-form-line-small-title"> sex</span></label>
                            <div class="am-u-sm-9">
          						 <label class="am-radio-inline">
          						 	<c:if test="${user.sex == 1}">
							        	<input type="radio"  value="1" name="sex" checked> 男
          						 	</c:if>
          						 	<c:if test="${user.sex !=1}">
							        	<input type="radio"  value="1" name="sex" > 男
          						 	</c:if>
							      </label>
							      <label class="am-radio-inline">
							      	<c:if test="${user.sex == 0}">
							        	<input type="radio"  value="1" name="sex" checked> 女
          						 	</c:if>
          						 	<c:if test="${user.sex != 0}">
							        	<input type="radio"  value="1" name="sex" > 女
          						 	</c:if>
							      </label>
							      <!-- <label class="am-radio-inline">
							        <input type="radio" name="sex"> 其他
							      </label> -->
                            </div>
                        </div>
                        
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">电话<span class="tpl-form-line-small-title"> phone</span></label>
                            <div class="am-u-sm-9">
          						 <input type="text" class="tpl-form-input" id="phone" name ="phone" value="${user.phone}" placeholder="电话">
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>
                        
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">所属公司<span class="tpl-form-line-small-title"> company</span></label>
                            <div class="am-u-sm-9">
                            	<c:if test="${loginUser.isAdmin ==2}">
          						 	<input type="text" class="tpl-form-input" id="company" name ="company" value="${loginUser.company}" placeholder="所属公司" readonly ="readonly">
                            	</c:if>
                            	<c:if test="${loginUser.isAdmin==1}">
          						 	<input type="text" class="tpl-form-input" id="company" name ="company" value="${user.company}" placeholder="所属公司" readonly ="readonly">
                            	</c:if>
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>
                        
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">航班号<span class="tpl-form-line-small-title"> traffic</span></label>
                            <div class="am-u-sm-9">
          						 <input type="text" class="tpl-form-input" id="traffic" name ="traffic" value="${user.traffic}" placeholder="航班号或车次号">
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>
                        
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">身份证号<span class="tpl-form-line-small-title"> idCard</span></label>
                            <div class="am-u-sm-9">
          						 <input type="text" class="tpl-form-input" id="idCard" name ="idCard" value="${user.idCard}" placeholder="身份证号">
                                <!-- <small>请填写标题文字10-20字左右。</small> -->
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-email" class="am-u-sm-3 am-form-label">出发时间 <span class="tpl-form-line-small-title">departureTime</span></label>
                            <div class="am-u-sm-9">
                               <%--  <input type="text" class="am-form-field tpl-form-no-bg" placeholder="出发时间"  name = "departureTime" value="${user.departureTime}"  data-am-datepicker="" readonly=""> --%>
                               <input type="text"  name = "departureTime" value="${user.departureTime}"  id="departureTime" class="am-input-group date" placeholder="出发时间" readonly="readonly">
                                <!-- <small>发布时间为必填</small> -->
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-email" class="am-u-sm-3 am-form-label">到达时间 <span class="tpl-form-line-small-title">arrivalTime</span></label>
                            <div class="am-u-sm-9">
                               <%--  <input type="text" class="am-form-field tpl-form-no-bg" placeholder="到达时间"  name = "arrivalTime" value="${user.arrivalTime}"  data-am-datepicker="" readonly=""> --%>
                               <input type="text" name = "arrivalTime" value="${user.arrivalTime}" id="arrivalTime" class="am-input-group date" placeholder="到达时间" readonly="readonly">
                                <!-- <small>发布时间为必填</small> -->
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-email" class="am-u-sm-3 am-form-label">离开时间 <span class="tpl-form-line-small-title">leaveTime</span></label>
                            <div class="am-u-sm-9">
                                <%-- <input type="text" class="am-form-field tpl-form-no-bg" placeholder="离开时间"  name = "leaveTime" value="${user.leaveTime}"  data-am-datepicker="" readonly=""> --%>
                                <input type="text" name = "leaveTime" value="${user.leaveTime}"  id="leaveTime" class="am-input-group date" placeholder="离开时间" readonly="readonly">
                                <!-- <small>发布时间为必填</small> -->
                             </div>
                         </div>

                         <div class="am-form-group">
                             <label for="user-phone" class="am-u-sm-3 am-form-label">是否安排住宿<span class="tpl-form-line-small-title"> accommodation</span></label>
                             <div class="am-u-sm-9">
                                <label class="am-radio-inline">
                                	<c:if test="${user.isAccommodation == 1}">
							        	<input type="radio"  value="" name="accommodation" value = "1" checked>是
                                	</c:if>
                                	<c:if test="${user.isAccommodation != 1}">
							        	<input type="radio"  value="" name="accommodation" value = "1" >是
                                	</c:if>
							      </label>
							      <label class="am-radio-inline">
							      	<c:if test="${user.isAccommodation == 0}">
							        	<input type="radio"  value="0" name="accommodation"  checked>否
                                	</c:if>
							      	<c:if test="${user.isAccommodation != 0}">
							        	<input type="radio"  value="0" name="accommodation" >否
                                	</c:if>
							      </label>
                             </div>
                         </div>


                        <!-- <div class="am-form-group">
                             <label for="user-weibo" class="am-u-sm-3 am-form-label">添加分类 <span class="tpl-form-line-small-title">Type</span></label>
                             <div class="am-u-sm-9">
                                 <input type="text" id="user-weibo" placeholder="请添加分类用点号隔开">
                                 <div>

                                 </div>
                             </div>
                         </div> -->


                         <div class="am-form-group">
                             <div class="am-u-sm-9 am-u-sm-push-3">
                                 <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success">提交</button>
                             </div>
                         </div>
                     </form>
                 </div>
             </div>
         </div>
     </div>
    <script src="<%=basePath%>/resources/assets/js/amazeui.min.js"></script>
    <script src="<%=basePath%>/resources/assets/js/app.js"></script>
    
	<script src="<%=basePath%>/resources/js/mui/mui.min.js"></script>
	<%-- <script  src="<%=basePath%>/resources/js/jquery-1.9.0/jquery.min.js"></script> --%>
    <script>
		    $('.am-input-group.date').datetimepicker({
		    	  format: 'yyyy-mm-dd hh:ii',
		    	  language:  'zh-CN',
		    	  autoclose: 1
		    });
		    

		   /*  document.getElementsByName('input的name名称')[0].addEventListener('click',myfunc)
		    function myfunc(e){
		        e.currentTarget.blur();
		    } */
		    
			function verification(){
				var result=false;
				var userId = $("#userId").val();
				var userName = $("#userName").val();
				var realName =  $("#realName").val();
				var phone =  $("#phone").val();
				var company =  $("#company").val();
				var traffic =  $("#traffic").val();
				var idCard =  $("#idCard").val();
				var departureTime =  $("#departureTime").val();
				var arrivalTime =  $("#arrivalTime").val();
				var leaveTime =  $("#leaveTime").val();
				
				var sexName = document.getElementsByName("sex");
				debugger;
				var sex = "1";
				for(i=0;i<sexName.length;i++){
					if(sexName[i].checked){
						sex = sexName[i].value;
					}
				}
				
				var accommodationName = document.getElementsByName("accommodation");
				var accommodation = "0";
				for(i=0;i<accommodationName.length;i++){
					if(accommodationName[i].checked){
						accommodation = accommodationName[i].value;
					}
				}
				
				var dataJson = {"userId":userId,"sex":sex,"userName":userName,"realName":realName,"phone":phone,"company":company,"traffic":traffic,"idCard":idCard,"departureTime":departureTime,"arrivalTime":arrivalTime,"leaveTime":leaveTime,"isAccommodation":accommodation};
				
				if($('#realName').val().length<=0){
					mui.alert("姓名不能为空！",'提示');
					return result;
				} 
				
				/* if (!phoneReg.exec(phone)){
					 mui.alert("请输入正确的手机号！",'提示');
					 return result;
				} */
				
				debugger;
 			   if(!result){
 				   debugger;
					 mui.ajax('${ctx}/userSystem/inUpUserData',{
						data:dataJson,
						dataType:'json',
						type:'post',
						async:false,
						success:function(data){
							if(data==1 || data=="1"){
								result = true ;
							}else if(data==2 || data=="2"){
								mui.alert("该用户名已存在，请修改用户名！",'提示');
							}else{
								mui.alert("插入或更新失败，请稍后重试！",'提示');
							}
						}
					});  
					return result;
				}
				
			 }
			
			
		</script>

</body>
	
</html>
